//
//  MoveCarTimeCell.m
//  carcareIOS
//
//  Created by 王然 on 16/9/19.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "MoveCarTimeCell.h"
#define WORD_COLOR (COLOR_HEXSTRING(@"#191919"))
@interface MoveCarTimeCell()

@property (nonatomic , strong) UIView * backV;

@property (nonatomic , strong) UIView * bottomLineV;

@end
@implementation MoveCarTimeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    self.backV = [[UIView viewWithFrame:CGRectMake(0, 0, __MAIN_WIDTH, CELL_HEIGHT)] setupOnView:self];
    CGFloat lableX = 17 * __MAIN_RATIO_375;
    UIImage * rightImage = ImageNamed(@"cell_right");
    UIImageView * rightIV = [Factory imageViewWithCenter: CGPointMake(__MAIN_WIDTH - 25, CELL_HEIGHT / 2) image:rightImage onView:self.backV];
    
    CGFloat smallLW = 25;
    CGFloat bigAndSmallRightX = 5 ;
    CGFloat bigLW = (__MAIN_WIDTH - (smallLW + bigAndSmallRightX) * 2 - lableX - (__MAIN_WIDTH - rightIV.left)) / 2;
    UILabel * smallOneL =  [[UILabel labelWithFrame:CGRectMake(lableX, 0, smallLW, CELL_HEIGHT) font:FONT_DEFAULT_Light(20) text:@"从" textColor:WORD_COLOR] setupOnView:self.backV];
    self.startTimeL = [[[UILabel labelWithFrame:CGRectMake(smallOneL.right, 0, bigLW, CELL_HEIGHT) font:FONT_DEFAULT_Light(20) text:@"" textColor:COLOR_HEXSTRING(@"#1f90e5")] setupOnView:self.backV] labelResetTextAlignment:NSTextAlignmentCenter];
    UILabel * smallTwoL = [[UILabel labelWithFrame:CGRectMake(self.startTimeL.right + bigAndSmallRightX, 0, smallLW, CELL_HEIGHT) font:smallOneL.font text:@"至" textColor:WORD_COLOR] setupOnView:self.backV];
    self.endTimeL = [[[UILabel labelWithFrame:CGRectMake(smallTwoL.right, 0, bigLW, CELL_HEIGHT) font:self.startTimeL.font text:@"" textColor:self.startTimeL.textColor] setupOnView:self.backV] labelResetTextAlignment:NSTextAlignmentCenter];
    
    [[[UIView viewWithFrame:CGRectMake(lableX, 0, __MAIN_WIDTH - lableX, 0.5)] setupOnView:self.backV] resetBackgroundColor:[Theme lineNewColor]];
    self.bottomLineV = [[[UIView viewWithFrame:CGRectMake(0, CELL_HEIGHT - 0.5, __MAIN_WIDTH, 0.5)] setupOnView:self] resetBackgroundColor:[Theme lineNewColor]];
    
}
- (void)reloadDataWithModel:(MoveCarSettingModel *)model
{
    self.startTimeL.text = ([model.startTime isNotNil] ? model.startTime : @"21:00");
    self.endTimeL.text = ([model.endTime isNotNil] ? model.endTime : @"07:00");
}
- (void)setIsHiddenTimeCell:(BOOL)isHiddenTimeCell
{
    _isHiddenTimeCell = isHiddenTimeCell;
    [self.backV setHidden:isHiddenTimeCell];
    [self.bottomLineV setTop:(isHiddenTimeCell ? 0 : (CELL_HEIGHT - 0.5))];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
